<template>
  <div>
    <tableTpl
      :data="data"
      :columns="columns1"
      v-on:changeItem="changeItem"
      :tableLoading="loading"
    >
      <div slot="table_nav" v-if="current_index >= 3">
        <a-tabs type="card" @change="getData" v-model="paramsData.threeTypeId">
          <a-tab-pane key="" tab="全部"> </a-tab-pane>
          <a-tab-pane key="1" tab="录制技术"> </a-tab-pane>
          <a-tab-pane key="2" tab="播出技术"> </a-tab-pane>
        </a-tabs>
      </div>
      <div
        slot="rightHtml"
        slot-scope="{ record }"
        class="flexLeft"
        v-if="current_index % 2 != 0"
      >
        <a-button
          @click="showPopup('tg', record)"
          :disabled="record.taskEnable != 1"
          type="link"
        >
          <span class="fontS20 flexCon"> 是否通过 </span>
        </a-button>
        <!-- <a-button
          @click="showPopup('bh', record)"
          :disabled="record.taskEnable != 1"
          type="link"
        >
          <span class=""> 驳回 </span>
        </a-button> -->
      </div>
      <!-- <a-button
        @click="showPopup('look', record)"
        :disabled="record.taskEnable != 1"
        type="link"
        slot="rightHtml"
        slot-scope="{ record }"
        v-else
      >
        <span class="flexCon fontS20"> 查看意见 </span>
      </a-button> -->
    </tableTpl>
    <dynamic-form
      :formData="formData"
      :recordData="record"
      ref="dynamic"
      @confirm="getData()"
    />
    <popup
      ref="popup"
      title="提示"
      :count="popText"
      @confirm="popConfirm"
    ></popup>
  </div>
</template>

<script>
import popup from "../components/pop/popup.vue";
import tableTpl from "../components/tableTpl/tableTpl.vue";
import dynamicForm from "../components/dynamicForm/dynamicForm.vue";
import { mapState } from "vuex";
import { tasklist, ByInstanceId } from "@/api";
import { investigate } from "@/assets/js/declare";
export default {
  components: {
    tableTpl,
    dynamicForm,
    popup,
  },
  data() {
    return {
      data: [], //表格所需数据
      record: {},
      popText: "",
      paramsData: investigate[0].child[0].dataType, // 接口参数
      current_index: investigate[0].child[0].index,
      loading: false,
      columns1: [
        // 单位推荐、形式审查、专家评审
        {
          title: "序号",
          dataIndex: "key",
          width: 80,
        },
        {
          title: "申报单位",
          dataIndex: "deptName",
          width: 150,
        },
        {
          title: "作品名称",
          width: 150,
          key: "name",
          slots: { title: "baseName" },
          scopedSlots: { customRender: "name" },
        },
        {
          title: "主要完成人",
          dataIndex: "doneUsers",
          width: 150,
        },
        {
          title: "奖项等级",
          dataIndex: "grade",
          width: 150,
          scopedSlots: { customRender: "grade" },
          // filters: [
          //   {
          //     text: "Joe",
          //     value: "Joe",
          //   },
          //   {
          //     text: "Jim",
          //     value: "Jim",
          //   },
          // ],
          filterMultiple: false,
        },
        // {
        //   title: '申请时间',
        //   dataIndex: 'createTime',
        //   width: 150,
        // },
        {
          title: "审核状态",
          dataIndex: "stateName",
          width: 150,
        },
        {
          title: "操作",
          key: "action",
          scopedSlots: { customRender: "action" },
          width: 190,
          fixed: "right",
        },
      ],
    };
  },
  provide() {
    return {
      leftList: investigate,
    };
  },
  created() {
    this.getData();
  },
  computed: {
    ...mapState(["formData"]),
  },
  methods: {
    changeItem(k) {
      this.paramsData = k.dataType;
      console.log(this.paramsData);
     if (this.paramsData.twoTypeId == 1) {
        this.columns1 = [
          // 单位推荐、形式审查、专家评审
          {
            title: "序号",
            dataIndex: "key",
            width: 80,
          },
          {
            title: "申报单位",
            dataIndex: "deptName",
            width: 150,
          },
          {
            title: "作品名称",
            width: 150,
            key: "name",
            slots: { title: "baseName" },
            scopedSlots: { customRender: "name" },
          },
          {
            title: "主要完成人",
            dataIndex: "doneUsers",
            width: 150,
          },
          {
            title: "类别",
            dataIndex: "kind",
            width: 150,
            scopedSlots: { customRender: "kind" },
            // filters: [
            //   {
            //     text: "Joe",
            //     value: "Joe",
            //   },
            //   {
            //     text: "Jim",
            //     value: "Jim",
            //   },
            // ],
            filterMultiple: false,
          },
          {
            title: "客观图形分（初评）",
            dataIndex: "evaluateImage",
            width: 150,
          },
          {
            title: "客观声音分（初评）",
            dataIndex: "evaluateVoice",
            width: 150,
          },
          {
            title: "主观分（复评）",
            dataIndex: "evaluationF",
            width: 150,
          },
          {
            title: "严重缺陷",
            dataIndex: "seriousBug",
            width: 150,
          },
          {
            title: "总分",
            dataIndex: "seriousBug",
            width: 150,
          },
          // {
          //   title: "联系人",
          //   dataIndex: "seriousBug",
          //   width: 150,
          // },
          // {
          //   title: "联系电话",
          //   dataIndex: "seriousBug",
          //   width: 150,
          // },
          // {
          //   title: '申请时间',
          //   dataIndex: 'createTime',
          //   width: 150,
          // },
          {
            title: "审核状态",
            dataIndex: "stateName",
            width: 150,
          },
          {
            title: "操作",
            key: "action",
            scopedSlots: { customRender: "action" },
            width: 190,
            fixed: "right",
          },
        ];
      } else if (this.paramsData.twoTypeId == 2) {
        this.columns1 = [
          // 单位推荐、形式审查、专家评审
          {
            title: "序号",
            dataIndex: "key",
            width: 80,
          },
          {
            title: "申报单位",
            dataIndex: "deptName",
            width: 150,
          },
          {
            title: "作品名称",
            width: 150,
            key: "name",
            slots: { title: "baseName" },
            scopedSlots: { customRender: "name" },
          },
          {
            title: "主要完成人",
            dataIndex: "doneUsers",
            width: 150,
          },
          {
            title: "类别",
            dataIndex: "kind",
            width: 150,
            scopedSlots: { customRender: "kind" },
            // filters: [
            //   {
            //     text: "Joe",
            //     value: "Joe",
            //   },
            //   {
            //     text: "Jim",
            //     value: "Jim",
            //   },
            // ],
            filterMultiple: false,
          },
          {
            title: "录音电平",
            dataIndex: "evaluateRecordingLevel",
            width: 150,
          },
          {
            title: "噪声",
            dataIndex: "evaluateNoise",
            width: 150,
          },
          {
            title: "失真",
            dataIndex: "evaluateDistortion",
            width: 150,
          },
          {
            title: "复接和剪接技术",
            dataIndex: "evaluateMultiplex",
            width: 150,
          },
          {
            title: "声道平衡",
            dataIndex: "evaluateChannelBalance",
            width: 150,
          },
          {
            title: "相位",
            dataIndex: "evaluatePhase",
            width: 150,
          },
          // {
          //   title: "广播电台呼号",
          //   dataIndex: "evaluateBroadcasting",
          //   width: 150,
          // },
          // {
          //   title: "联系人",
          //   dataIndex: "seriousBug",
          //   width: 150,
          // },
          // {
          //   title: "联系电话",
          //   dataIndex: "seriousBug",
          //   width: 150,
          // },
          // {
          //   title: '申请时间',
          //   dataIndex: 'createTime',
          //   width: 150,
          // },
          {
            title: "审核状态",
            dataIndex: "stateName",
            width: 150,
          },
          {
            title: "操作",
            key: "action",
            scopedSlots: { customRender: "action" },
            width: 190,
            fixed: "right",
          },
        ];
      } else {
        this.columns1 = [
          // 单位推荐、形式审查、专家评审
          {
            title: "序号",
            dataIndex: "key",
            width: 80,
          },
          {
            title: "申报单位",
            dataIndex: "deptName",
            width: 150,
          },
          {
            title: "作品名称",
            width: 150,
            key: "name",
            slots: { title: "baseName" },
            scopedSlots: { customRender: "name" },
          },
          {
            title: "主要完成人",
            dataIndex: "doneUsers",
            width: 150,
          },
          {
            title: "奖项等级",
            dataIndex: "grade",
            width: 150,
            scopedSlots: { customRender: "grade" },
            // filters: [
            //   {
            //     text: "Joe",
            //     value: "Joe",
            //   },
            //   {
            //     text: "Jim",
            //     value: "Jim",
            //   },
            // ],
            filterMultiple: false,
          },
          // {
          //   title: '申请时间',
          //   dataIndex: 'createTime',
          //   width: 150,
          // },
          {
            title: "审核状态",
            dataIndex: "stateName",
            width: 150,
          },
          {
            title: "操作",
            key: "action",
            scopedSlots: { customRender: "action" },
            width: 190,
            fixed: "right",
          },
        ];
      }
      this.current_index = k.index;
      this.getData();
    },
    // 获取页面数据
    async getData() {
      this.loading = true;
      const res = await tasklist(this.paramsData);
      this.loading = false;
      if (res.code != 200) return;
      res.rows.forEach((i, k) => {
        i.key = k + 1;
      });
      this.data = res.rows;
    },
    showPopup(type, record) {
      switch (type) {
        case "tg":
          this.record = record;
          this.$refs.dynamic.showForm();
          this.$store.dispatch("GET_USER_DATA", record.taskId);
          break;
        case "look":
          ByInstanceId(record.baseId, 2).then((res) => {
            this.popText =
              res.data.length > 0
                ? res.data[0].formHistoryDataDTO[1].value
                : "暂无";
          });
          this.$refs.popup.showPop();
          break;
        case "ch":
          this.popText = "是否确认撤回";
          this.$refs.popup.showPop();
          break;
        case "bh":
          this.popText = "是否确认驳回";
          this.$refs.popup.showPop();
          break;
      }
    },
    popConfirm() {
      console.log("点击确认");
      this.$refs.popup.hidePop();
    },
  },
};
</script>

<style scoped>
.popLeftText {
  width: 82px;
  text-align: end;
}
</style>